import React from 'react'
import { App } from 'antd'
import { useEffect } from 'react'
import { Link } from 'umi'
import { useModel, history } from '@umijs/max'

function CheckCustomerService() {
  const { GetBaseInfo } = useModel('BaseSet')
  const { modal } = App.useApp()

  useEffect(() => {
    showCustomerService()
  }, [])

  const baseSet = '/baseSet'

  const showCustomerService = async () => {
    const res = await GetBaseInfo()

    if (res) {
      if (Array.isArray(res)) {
        modal.confirm({
          title: '客服配置缺失',
          content: (
            <div>
              当前客服配置为空,请前往
              <Link to={baseSet}>客服配置</Link>
              页面配置客服信息
            </div>
          ),
          okText: '去配置',
          cancelText: '关闭',
          onOk() {
            history.push(baseSet)
          }
        })
      }
    }
  }
  return <div></div>
}

export default CheckCustomerService
